﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Drawing;

namespace it_security_project.App_Code.BusinessLogicLayer
{
    public class CaptchaGenerator
    {
        public List<Captcha> captchaList = new List<Captcha>();
        private List<String> namelist = new List<string>() {"ANAL TIGER", "FITT POTATIS","BLASK PENETRATION","GROV KORV","DIN MAMMA", "KOKAD VASKA", "ANAL TIGER", "TITAN TROSA", "RAKAD FISKPINNE", "TOALETT JUDE", "RAPED TOARULLE", "SITT KISSARE MED POLIO", "PATENTERAD JUGGE", "RASIST KATTER", "BACKWARDS PUSSY", "IMMORTAL SPETTKAKA", "NERKISSAD GRIS", "NERDY STAIRWAY"};

        public Captcha GetCaptcha()
        {
            
            Random rnd = new Random();
            int i = rnd.Next(0, 18);
            if (captchaList.Count == 0)
            {
                GenerateCaptcha(); 
            }            

            Captcha c = new Captcha();
            c.ImageURL = captchaList[i].ImageURL;
            c.Name = captchaList[i].Name;

            return c;
        }


        private void GenerateCaptcha()
        {
            for (int i = 0; i < 18; i++)
            {
                Captcha c = new Captcha();

                c.ImageURL = "~/Content/" + i + ".png?" + DateTime.Now.Ticks.ToString();
                c.Name = namelist[i];

                captchaList.Add(c);
            }
        }
    }
}